<?php
/*
 * @Created by: wangchengcheng
 * @Author: wangchengcheng
 * @Date: 2020-01-01 20:32:34
 * @LastEditors  : wangchengcheng
 * @LastEditTime : 2020-01-02 11:33:57
 */

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        $file = collect(File::files(database_path('seeds')))
            ->transform(function($v){
                return [
                    'cTime' => $v->getCtime(),
                    'filename' => basename($v->getFilename(), '.php'),
                ];
            })
            ->filter(function($v){
                return $v['filename'] === 'DatabaseSeeder' ? false : true;
            })
            ->sortBy('cTime')
            ->pluck('filename');
            
        //自动call目录下的文件
        foreach($file as $k => $v){
            $this->call($v);
        }
        
    }
}
